import React, { Dispatch } from 'react';
import { AssetMaintenanceManageAPI } from '../common/type';
import { FormInstance } from 'antd';

interface AsssetListTableTypes {
  dataSource: Record<string, any>[]; //表格数据
  loading: boolean; // 加载
  mapList: Record<string, any>;
  assetForm: any; // 选中的资产信息表单
  pagination: Record<string, any>; //分页参数
  otherParams: Record<string, any>; //当前请求参数
  searchList: AssetMaintenanceManageAPI.ISearchList;
  reloadTableData: () => void; // 重置
  [key: string]: any;
}

/**
 * Context 默认值类型
 */
type ManageContextTypes = {
  prefixCls: string;
  styleFixCls: string;
  assetForm: FormInstance | any;
  curRes: Record<string, any>; // 权限
  assetListDispatch: Dispatch<any>; // 派发
  selectAssetList: Record<string, any>[]; // 选中的资产列表
  addAssetList: any;
};

/**
 * useContext
 * @rightTableProps 公共表格所需参数
 * @curRes 权限
 * @assetListDispatch reduce 派发器
 */
const INIT_ASSETLISTMANAGE_CONTEXT: ManageContextTypes = {
  prefixCls: 'apply-update',
  styleFixCls: 'contract-styfixcls-',
  assetForm: {},
  selectAssetList: [],
  addAssetList: [],
  curRes: {},
  assetListDispatch: () => {},
};

const AssetListManageContext = React.createContext(INIT_ASSETLISTMANAGE_CONTEXT);

export { AssetListManageContext };
